package org.jeecg.modules.homepage.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.earlywarning.information.service.IEwInformationService;
import org.jeecg.modules.earlywarning.rules.entity.EwRules;
import org.jeecg.modules.earlywarning.rules.service.IEwRulesService;
import org.jeecg.modules.homepage.vo.SummaryVo;
import org.jeecg.modules.homepage.vo.Zqvo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * @Description: 首页
 * @Author: 贾送兵
 * @Date:   2021-11-30
 * @Version: V1.0
 */
@Api(tags="首页")
@RestController
@RequestMapping("/homePage")
@Slf4j
public class HomePageController extends JeecgController<EwRules, IEwRulesService> {
	@Autowired
	private IEwInformationService ewInformationService;//预警




	@AutoLog(value = "首页")
	@ApiOperation(value="首页", notes="首页")
	@GetMapping(value = "/list")
	public Result<?> list(HttpServletRequest req) {

		//挡板数据
		SummaryVo s = new SummaryVo();//水数据组装
		s.setCumulativeCost("1000");
		s.setCumulativeCostPerc("10%");
		s.setCumulativeCostState("1");//1代表上升 2代码下降

		s.setCumulativeWater("5555");
		s.setCumulativeWaterPerc("20%");
		s.setCumulativeWaterState("2");

		s.setSlaughterNum("3000");
		s.setSlaughterNumPerc("10%");
		s.setSlaughterNumState("1");
		List<Integer> list111 = new ArrayList<>();
		for (int i = 10; i < 18; i++) {
			list111.add(i);
		}
		s.setSlaughterNumList(list111);


		SummaryVo d = new SummaryVo();//电数据组装
		d.setCumulativeCost("1000");
		d.setCumulativeCostPerc("10%");
		d.setCumulativeCostState("1");//1代表上升 2代码下降

		d.setCumulativeWater("5555");
		d.setCumulativeWaterPerc("20%");
		d.setCumulativeWaterState("2");

		d.setSlaughterNum("3000");
		d.setSlaughterNumPerc("10%");
		d.setSlaughterNumState("1");
		List<Integer> list2 = new ArrayList<>();
		for (int i = 10; i < 18; i++) {
			list2.add(i);
		}
		d.setSlaughterNumList(list2);

		SummaryVo rq = new SummaryVo();//燃气数据组装
		rq.setCumulativeCost("1000");
		rq.setCumulativeCostPerc("10%");
		rq.setCumulativeCostState("1");//1代表上升 2代码下降

		rq.setCumulativeWater("5555");
		rq.setCumulativeWaterPerc("20%");
		rq.setCumulativeWaterState("2");

		rq.setSlaughterNum("3000");
		rq.setSlaughterNumPerc("10%");
		rq.setSlaughterNumState("1");
		List<Integer> list3 = new ArrayList<>();
		for (int i = 10; i < 18; i++) {
			list3.add(i);
		}
		rq.setSlaughterNumList(list3);

		SummaryVo zq = new SummaryVo();//蒸汽数据组装
		zq.setCumulativeCost("1000");
		zq.setCumulativeCostPerc("10%");
		zq.setCumulativeCostState("1");//1代表上升 2代码下降

		zq.setCumulativeWater("5555");
		zq.setCumulativeWaterPerc("20%");
		zq.setCumulativeWaterState("2");

		zq.setSlaughterNum("3000");
		zq.setSlaughterNumPerc("10%");
		zq.setSlaughterNumState("1");
		List<Integer> list4 = new ArrayList<>();
		for (int i = 10; i < 18; i++) {
			list4.add(i);
		}
		rq.setSlaughterNumList(list4);


		//组装数据
		Map<String,Object> map = new HashMap<>();
		map.put("sNum",s);//水
		map.put("dNum",d);//电
		map.put("rqNum",rq);//燃气
		map.put("zqNum",zq);//蒸汽
		return  Result.OK(map);
	}





	@AutoLog(value = "年度能耗分析")
	@ApiOperation(value="年度能耗分析", notes="年度能耗分析")
	@ApiImplicitParams(value = {
			@ApiImplicitParam(name = "type", value = "能源类型标识，燃气输入RQ，蒸汽输入ZQ，水输入S，电输入DB", dataType = "String", required = true),
			@ApiImplicitParam(name = "year", value = "年份", dataType = "String", required = true)
	})
	@GetMapping(value = "/yearEnergyConsumption")
	public Result<?> yearEnergyConsumption(HttpServletRequest req) {

		//费用
		List list = new ArrayList();

		for (int i = 100; i < 107; i++) {
		list.add(i);
		}

		//能耗
		List list2 = new ArrayList();

		for (int i = 120; i < 127; i++) {
			list2.add(i);
		}
		//组装数据
		Map<String,Object> map = new HashMap<>();
		map.put("fyList",list);//费用
		map.put("nhList",list2);//能耗
		return  Result.OK(map);
	}




	@AutoLog(value = "水电燃蒸分析")
	@ApiOperation(value="水电燃蒸分析", notes="水电燃蒸分析")
	@GetMapping(value = "/energYanalysisChart")
	public Result<?> energYanalysisChart(HttpServletRequest req) {



		//蒸汽
		Zqvo zq1= new Zqvo();
		zq1.setName("北京");
		zq1.setValue("300");

		Zqvo zq2= new Zqvo();
		zq2.setName("石家庄");
		zq2.setValue("600");

		Zqvo zq3= new Zqvo();
		zq3.setName("郑州");
		zq3.setValue("100");

		Zqvo zq4= new Zqvo();
		zq4.setName("秦皇岛");
		zq4.setValue("100");

		//电
		List dList = new ArrayList();
		dList.add(zq1);
		dList.add(zq2);
		dList.add(zq3);
		dList.add(zq4);

		List<Zqvo> zqList = new ArrayList();
		zqList.add(zq1);
		zqList.add(zq2);
		zqList.add(zq3);
		zqList.add(zq4);

		//水
		List sList = new ArrayList();
		sList.add(zq1);
		sList.add(zq2);
		sList.add(zq3);
		sList.add(zq4);

		//燃气
		List<Zqvo> rqList = new ArrayList();
		Zqvo zq5= new Zqvo();
		zq4.setName("上海");
		zq4.setValue("700");

		Zqvo zq6= new Zqvo();
		zq6.setName("长春");
		zq6.setValue("900");
		rqList.add(zq5);
		rqList.add(zq6);
		rqList.add(zq4);
		rqList.add(zq3);
		rqList.add(zq2);
		rqList.add(zq1);
       /*  以上为挡板数据*/




		//组装数据
		Map<String,Object> map = new HashMap<>();
		map.put("dList",dList);//电能源分析
		map.put("zqList",zqList);//蒸汽能源分析
		map.put("sList",sList);//水能源分析
		map.put("rqList",rqList);//燃气能源分析
		return  Result.OK(map);
	}



}
